Skip to content

Remove /clr:pure from WPF C++/CLI projects#11575

Merged
vinnarayana-msft merged 6 commits into
dotnet:mainfrom
vinnarayana-msft:user/vinnarayana/remove-clr-pure-main
May 13, 2026
Merged

Remove /clr:pure from WPF C++/CLI projects#11575
vinnarayana-msft merged 6 commits into
dotnet:mainfrom
vinnarayana-msft:user/vinnarayana/remove-clr-pure-main

Conversation

@vinnarayana-msft

@vinnarayana-msft vinnarayana-msft commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Description

MSVC 14.51 (VS 18.3) is removing support for /clr:pure when used with /clr:netcore. WPF is the only known consumer of /clr:pure. This PR migrates the two affected C++/CLI projects (DirectWriteForwarder.vcxproj and System.Printing.vcxproj) from /clr:pure to standard /clr:netcore (IJW mixed mode).

Changes:

  • Changed CLRSupport and CompileAsManaged from pure to NetCore in both vcxproj files
  • Updated Wpf.Cpp.props to remove the pure to NetCore conversion logic in ManagedCxx conditions
  • Removed ijwhost.dll from packaging exclusions in both vcxproj files — mixed-mode assemblies require this .NET runtime bootstrap shim to load correctly
  • Fixed ARM64 build break in intsafe_private_copy.h where _M_ARM64 was missing from an architecture detection #if condition (previously masked by _M_CEE_PURE)

Customer Impact

Without this fix, WPF will fail to build with MSVC 14.51+ (VS 18.3) since /clr:pure + /clr:netcore will no longer be a valid combination. This is a build-time breaking change from the MSVC toolset.

Regression

No. This is a proactive change to address an upcoming MSVC toolset deprecation. No existing behavior is regressed — the output DLLs function identically at runtime.

Testing

Test Result
x64 build ✅ Pass
ARM64 build compilation ✅ Pass
WPF Gallery app run (x64) ✅ Pass

Risk

Low-Medium. The change is minimal (4 files) and surgical — it only affects the two C++/CLI projects in WPF. The runtime behavior of the DLLs is functionally equivalent; the difference is the compilation mode (pure MSIL → IJW mixed mode). The primary risk is potential performance impact from losing ahead-of-time MSIL compilation.

Microsoft Reviewers: Open in CodeFlow

Migrate DirectWriteForwarder and System.Printing from /clr:pure to
/clr:netcore (IJW mixed mode) in preparation for MSVC 14.51 which
removes /clr:pure + /clr:netcore support.

Changes:
- CLRSupport and CompileAsManaged changed from pure to NetCore
- Removed pure to NetCore conversion logic in Wpf.Cpp.props
- Removed ijwhost.dll packaging exclusion (required for mixed-mode)
- Added _M_ARM64 to architecture check in intsafe_private_copy.h

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vinnarayana-msft vinnarayana-msft requested review from a team and Copilot April 13, 2026 08:47
@dotnet-policy-service dotnet-policy-service Bot added the PR metadata: Label to tag PRs, to facilitate with triage label Apr 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates WPF’s C++/CLI build configuration to remove reliance on deprecated /clr:pure in favor of standard /clr:netcore (IJW mixed mode), aligning with upcoming MSVC toolset behavior and unblocking future builds.

Changes:

  • Switched CLRSupport and CompileAsManaged from pure to NetCore for DirectWriteForwarder and System.Printing.
  • Simplified Wpf.Cpp.props by removing the pureNetCore remapping logic and updating ManagedCxx conditions.
  • Fixed an ARM64 compilation break by extending architecture detection in intsafe_private_copy.h.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.DotNet.Wpf/src/System.Printing/System.Printing.vcxproj Moves the project to /clr:netcore and allows ijwhost.dll to be packaged by removing the exclusion.
src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj Moves the project to /clr:netcore and allows ijwhost.dll to be packaged by removing the exclusion.
src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/TtfDelta/intsafe_private_copy.h Adds _M_ARM64 handling to prevent ARM64 build errors.
eng/WpfArcadeSdk/tools/Wpf.Cpp.props Updates shared build logic to recognize CLRSupport=NetCore and removes the old pure remap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eng/WpfArcadeSdk/tools/Wpf.Cpp.props Outdated
@miloush

miloush commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Can we have some link/reference to the deprecation of the combination?

Copilot AI added a commit to dotnet/dotnet that referenced this pull request Apr 20, 2026
@vinnarayana-msft

Copy link
Copy Markdown
Contributor Author

Can we have some link/reference to the deprecation of the combination?
@miloush

Please refer to this page
This page says:

/clr:pure is deprecated. The option is removed in Visual Studio 2017 and later. We recommend that you port code that must be pure MSIL to C#.

The driver also gives a deprecation warning if /clr:pure is used:

cl : Command line warning D9035 : option 'clr:pure' has been deprecated and will be removed in a future release

@vinnarayana-msft

Copy link
Copy Markdown
Contributor Author

@vinnarayana-msft please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree company="Microsoft"

Comment thread eng/WpfArcadeSdk/tools/Wpf.Cpp.props Outdated
harshit7962
harshit7962 previously approved these changes May 8, 2026
Address PR review nit: remove CLRSupport=='pure' from DllRenameClause
condition since no project sets CLRSupport to 'pure' anymore. Update
comment to reference /clr:netcore instead of /clr:pure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vinnarayana-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

dipeshmsft
dipeshmsft previously approved these changes May 8, 2026
vinnarayana-msft and others added 2 commits May 11, 2026 09:01
…otnet-wpf-int build 20260512.2

On relative base path root
Microsoft.DotNet.Wpf.DncEng From Version 11.0.0-preview.2.26165.1 -> To Version 11.0.0-preview.2.26262.2
@vinnarayana-msft vinnarayana-msft merged commit e82267a into dotnet:main May 13, 2026
8 checks passed
mmanolova-msft added a commit to mmanolova-msft/dotnet that referenced this pull request Jun 3, 2026
After the /clr:pure to /clr:NetCore migration (dotnet/wpf#11575),
DirectWriteForwarder and System.Printing became mixed-mode C++/CLI assemblies
that require ijwhost.dll at runtime. The DLL was being placed in the managed
lib/ folder where it is not recognized by RuntimeList.xml, causing it to be
missing from self-contained publish output.

Move ijwhost.dll packaging logic to Packaging.targets centrally: exclude it
from the lib/ folder and route it to runtimes/win-{arch}/native/ so it is
properly included in the runtime pack manifest.

Fixes dotnet/wpf#11651

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mmanolova-msft added a commit to mmanolova-msft/dotnet that referenced this pull request Jun 4, 2026
The previous approach tried to include ijwhost.dll from the WPF C++/CLI project
output directories, but classic vcxproj files don't produce ijwhost.dll in their
output (the .NET SDK's UseIJWHost mechanism only works for SDK-style projects).

Instead, source ijwhost.dll directly from the Microsoft.NETCore.App.Host pack
(where it is built by the runtime repo) and include it as a NativeRuntimeAsset
in the WindowsDesktop shared framework runtime pack. This ensures it is present
at runtime for the mixed-mode C++/CLI assemblies (DirectWriteForwarder.dll,
System.Printing.dll) that depend on it after the /clr:pure to /clr:netcore
migration (dotnet/wpf#11575).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dipeshmsft pushed a commit that referenced this pull request Jun 12, 2026
* Package ijwhost.dll as native asset for self-contained publish

After the /clr:pure to /clr:NetCore migration (#11575), DirectWriteForwarder
and System.Printing became mixed-mode C++/CLI assemblies that require
ijwhost.dll at runtime. The DLL was being placed in the managed lib/ folder
where it is not recognized by RuntimeList.xml, causing it to be missing from
self-contained publish output.

Exclude ijwhost.dll from the lib/ packaging and add it as a native asset
under runtimes/win-{arch}/native/ so it is properly included in the runtime
pack manifest.

Fixes #11651

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Move ijwhost.dll packaging logic to Packaging.targets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants